#!/usr/bin/env python

import numpy
import pylab
import pipe_ex

def select_time(conn, cursor):
    return cursor.execute("SELECT time FROM log")

def select_date(conn, cursor):
    return cursor.execute("SELECT date FROM log")

conn, cursor = pipe_ex.setup_sqlite("sqlite3.db")
i = 0
buf_len = 0
for row in select_date(conn, cursor):
    for ele in row:
        buf_len += 1
    
buf = [buf_len]
for row in select_date(conn, cursor):
    print row[0]
    for ele in row:
        ele = buf[i]
    print buf
    i += 1
    
for row in select_time(conn, cursor):
    #print row[0]
    pass

pylab.plot_date(select_date(conn, cursor), select_time(conn, cursor), fmt='r-',
                tz=None, xdate=True, ydate=False )
#t = numpy.arange(0.0, 1.0+0.01, 0.01)
#s = numpy.cos(2*2*numpy.pi*t)
#pylab.plot(t, s)
 
pylab.xlabel('time (s)')
pylab.ylabel('voltage (mV)')
pylab.title('About as simple as it gets, folks')
pylab.grid(True)
pylab.savefig('simple_plot')
pylab.show()

